﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;

namespace SlideShow.Libraries
{
    public class RestServiceInvoker
    {
        public string GetMethod(string url) 
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                //establecer el metodo
                req.Method = "GET";
                //Recuperar la respuesta
                HttpWebResponse res = (HttpWebResponse)req.GetResponse();
                //Instanciar un lector
                StreamReader reader = new StreamReader(res.GetResponseStream());
                //Leer la cadena respondida
                string respuesta = reader.ReadToEnd();
                return respuesta;
            }
            catch (Exception e)
            {
                return e.Message;                
            }
            
        }
    }
}